<?php

class DataRestoreController extends Controller {
    var $name = 'DataRestore';
    var $components = array('database');

    function index() {
        $this->action = 'data_restore';
        $this->data_restore();
    }

    function data_restore() {
        $options = '';
        $datafiles = get_datafiles();
        foreach($datafiles as $file) {
            $file_info = explode('_', $file['file']);
                $options .= '<option value="' . $file['file'] . '">' . $file['file'] . ' ( ' . $file['size'] . ' backup on ' . date('y-m-d H:i', $file_info[1]) . ' )</option>';
            }
        $this->set('options', $options);
    }

    function ajax_data_restore($action, $file_name) {
        $this->layout = null;
        if ($action == 'restore' || $action == 'delete') {
            $database = new AcpDatabase();
            $result = $database->$action($file_name);
            __e($result);
        }
    }
}
?>
